<div class="container member-container">
    <?php include $this->getViewFile('../lib/leftmenu'); ?>
    <div class="col-md-10 member-con menber-score-con">
        <div class="title mb-common-title">兑换商品记录</div>
        <div class="content">
            <table id="table" width="885">
                <thead>
                  <tr>
                    <td class="bg_white" align="center" width="15%">兑换商品</td>
                    <td class="bg_white" align="center" width="10%">兑换积分</td>
                    <td class="bg_white" align="center" width="20%">兑换时间</td>
                    <td class="bg_white" align="center" width="45%">订单号</td>
                    <td class="bg_white" align="center" width="10%">订单状态</td>
                  </tr>
                </thead>
                <tbody>
                    <?php
                    $i = 0;
					foreach($models as $rs){
						$i++;
					?>
                    <tr data-id="<?php echo $rs->id ?>" <?php if($i % 2 == 0) echo "class='bg_white'"?>>
                        <input type="hidden" value="<?php echo $rs->RedeemModel->title ?>" name="title" id="title_<?php echo $rs->id ?>"/>
                        <td align="center" class="redeemrecord"><a id="url_<?php echo $rs->id ?>" href="<?php echo yii::app()->createUrl('/front/good/redeemskip', array('gid' => $rs->RedeemModel->id)) ?>" target="_blank"><img id="thumb_<?php echo $rs->id ?>" width="100px" height="100px" src="<?php echo $rs->RedeemModel->thumb?>" /></a></td>
                        <td align="center" class="redeemrecord"><?php echo $rs->integral?></td>
                        <td align="center" class="redeemrecord"><?php echo date('Y-m-d H:i:s',$rs->record_time) ?></td>
                        <td class="redeemrecord_order">
	                        <?php 
	                            //已经确定，返款或者已经拒绝
	                            if($rs->is_sure != RedeemRecordsModel::SURE_NOT):
							?>
								<span><?php echo $rs->order_sn; ?></span>
	                       	<?php else:?>
								<input style="height:30px" class="order_sn" data-id = "<?php echo $rs->id?>" placeholder = "填写订单号" type="text" value="<?php echo $rs->order_sn?>"/ >
								<div class="confim white bolder">确定</div>
	  						<?php endif ?>
							<br>
							<div class="share_jifenbtn bg_white">分享送积分</div>
							<div class="share_div" style="height:30px;display:none;">
								
								<div class="share-box">
					                <div class="share">
					                    <div class="title pull-left">分享到：</div>
					                    <div class="bdsharebuttonbox pull-left" data-tag="share_2" data-text="sh2" id="share_2">
					                        <a class="bds_weixin" data-cmd="weixin"></a>
					                        <a class="bds_sqq" data-cmd="sqq"></a>
					                        <a class="bds_tsina" data-cmd="tsina"></a>
					                        <a class="bds_qzone" data-cmd="qzone" href="#"></a>                                
					                        <!--<a class="bds_baidu" data-cmd="baidu"></a>
					                        <a class="bds_renren" data-cmd="renren"></a>-->
					                        
					                        <a class="bds_more" data-cmd="more"></a>
					                    </div>
					                    <div class="clearfix"></div>
					                </div>
					            </div>
								
							</div>
                        </td>
                        <td align="center" class="redeemrecord">
                        	<?php
                        	$is_sure = RedeemRecordsModel::getSureHtmlDetail($rs->is_sure);
                        	$is_refund = RedeemRecordsModel::getRefundHtmlDetail($rs->is_refund);
                        	if($is_sure == "已取消"):
                        		$is_sure_class = "pink";
                        	elseif ($is_sure == "已确定"):
                        		$is_sure_class = "green";
                        	else:
                        		$is_sure_class = "yellow";
                        	endif;
                        	
                        	if ($is_refund == "已返款"):
                        		$is_refund_class = "green";
                        	elseif ($is_refund == "未返款"):
                        		$is_refund_class = "yellow";
                        	endif;
                        	?>
                        	<p class='<?php echo $is_sure_class?>'><?php echo $is_sure?></p>
                        	<?php if($is_sure != '已取消') :?><p class='<?php echo $is_refund_class?>'><?php echo $is_refund?></p> <?php endif;?>
                        	<?php //echo RedeemRecordsModel::getSureHtmlDetail($rs->is_sure) ?>
                        	<?php //echo RedeemRecordsModel::getRefundHtmlDetail($rs->is_refund) ?>
                        </td>
                    </tr>
                    <?php
					}
					?>
                    <tr>
                            <td colspan="5" class="pager">
                                <?php
                                $this->widget('CLinkPager', array(
                                    'header' => "",
                                    'firstPageLabel' => '首页',
                                    'lastPageLabel' => '末页',
                                    'prevPageLabel' => '上一页',
                                    'nextPageLabel' => '下一页',
                                    'pages' => $pages,
                                    'footer' => "<span>共<em>{$pages->pageCount}</em>页</span>",
                                    'maxButtonCount' => 5
                                        )
                                );
                                ?>
                            </td>
                        </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="clearfix"></div>
</div>



<script src="<?php echo Yii::app()->params->staticUrl; ?>statics/js/ajaxForm.js"></script> 
<link rel="stylesheet" href="<?php echo Yii::app()->params->staticUrl; ?>statics/js/artDialog6/css/ui-dialog.css">
<script src="<?php echo Yii::app()->params->staticUrl; ?>statics/js/artDialog6/js/dialog-plus-min.js"></script> 
<script type="text/javascript">

    function change_order(objs)
    {
        var id = $(objs).data('id');
        var order_sn = $(objs).val();
        if(order_sn != '' && id > 0)
        {
            var data = {id:id,order_sn:order_sn};
        }else
        {
            dialog({
                title:'提示信息',
                content:'订单号不能为空',
            }).show();
            return false;
        }

        $.post('<?php echo YzwController::U("editOrder") ?>',data,function(rs){
            if(rs.status > 0){
                var d = dialog({
                    content:rs.info,
                    quickClose:true,
                    padding:'50',
                }).show();

                setTimeout(function () {
                    d.close().remove();
                }, 2000); 

                return;
            }else if(rs.status < 0){
                 var content = '';
                 var title = '检测到还需要填的信息没有填';
                 OBJ = dialog({
                    fixed: true,
                    title: title,
                    url:'<?php echo $this->createUrl("form") ?>',
                    cancelDisplay: false,
                    onclose:function(){
                       if(BIAO)
                       {
                         change_order(objs);
                       }
                                                  
                    }

                }).show();
                return true;
            }else{
                 dialog({
                    fixed: true,
                    title: '提示信息',
                    content: rs.info,
                    cancelDisplay: false,

                }).show();                
            }
        },'json');
    }


    var OBJ = {};
    var BIAO = '';
//    $(".order_sn").change(function()
//    {
//        change_order(this);
//    });

    $(".confim").click(function()
	{
    	var order_sn = $(this).prev();
		change_order(order_sn);
	});
    
    $('.share_jifenbtn').click(function(){
        $(this).hide();
        $(this).next().css('display','block');
    });
</script>

<script type="text/javascript">
    var RECORD_ID = '';
    $(function(){
        $("#table tr[data-id]").mouseover(function(){
            var obj = $(this);
            RECORD_ID = obj.data('id');
        })
    })
    window._bd_share_config = {
        common: {
            bdText: '【1折网官网】淘牛品U站官网1zw taoniupin 一折网 1折特卖网 天天特价 9.9包邮秒杀 9块9 九块九包邮 九块邮',
            bdDesc: '【1折网官网】淘牛品U站官网1zw taoniupin 一折网 1折特卖网 天天特价 9.9包邮秒杀 9块9 九块九包邮 九块邮',
            bdUrl: 'http://www.1zw.com',
            bdPic: '',
            onBeforeClick: function(cmd, config) {
                if (RECORD_ID !== '0') {
                    $.get('/user/redeem/recordgoodShare.html', {
                        id: RECORD_ID
                    }, function(data) {});
                    if ($('#' + RECORD_ID)) {
                        var share_text = $("title_" + RECORD_ID).html();
                        var share_pic = $("thumb_" + RECORD_ID).attr('src');
                        var share_url = $("url_" + RECORD_ID).attr('href');
                        return {
                            bdText: share_text,
                            bdUrl: share_url,
                            bdPic: share_pic
                        };
                    }
                }

            }
        },
        share: [{
            "bdSize": 16
        }]
    };
    with(document)
        //$.getScript('http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion=' + ~(-new Date()));
    0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?cdnversion=' + ~(-new Date() / 36e5)];
</script>